<?php
$module = !empty($module) ? $module : '';
$action = $this->uri->segment(3);
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="<?=PATH_URL.'static/images/admin/'?>favicon.png" type="image/x-icon" rel="icon" />
<link href="<?=PATH_URL.'static/images/admin/'?>favicon.png" type="image/x-icon" rel="shortcut icon" />
<link rel="stylesheet" href="<?=PATH_URL.'static/css/admin/'?>styles.css" type="text/css">
<link rel="stylesheet" href="<?=PATH_URL.'static/css/admin/'?>style_caledar.css" type="text/css">

<?php
if(!empty($css_list)){
	foreach($css_list as $css_file){
?>
	<link rel="stylesheet" href="<?=PATH_URL.'static/css/admin/'.$css_file?>" type="text/css">
<?
	}
}
?>

<script type="text/javascript">
var root = '<?=PATH_URL?>';
<?php if($module!='update_profile'){ ?>
var module = '<?=$module?>';
<?php } ?>
</script>
<script type="text/javascript" src="<?=PATH_URL.'static/js/jquery-1.8.1.min.js'?>"></script>
<script type="text/javascript" src="<?=PATH_URL.'static/js/jquery-ui-1.8.16.custom.min.js'?>"></script>
<script type="text/javascript" src="<?=PATH_URL.'static/editor/scripts/innovaeditor.js'?>"></script>
<script type="text/javascript" src="<?=PATH_URL.'static/js/admin/jquery.ToTop.js'?>"></script>
<!--<script type="text/javascript" src="<? //=PATH_URL.'static/js/admin/jquery_caledar.js'?>"></script>-->
<script type="text/javascript" src="<?=PATH_URL.'static/js/admin/custom_forms.js'?>"></script>
<script type="text/javascript" src="<?=PATH_URL.'static/js/admin/jquery.form.js'?>"></script>
<script type="text/javascript" src="<?=PATH_URL.'static/js/admin/jquery.url.js'?>"></script>
<script type="text/javascript" src="<?=PATH_URL.'static/js/admin/jquery.fancybox-1.3.4.pack.js'?>"></script>
<script type="text/javascript" src="<?=PATH_URL.'static/js/admin/admin.js'?>"></script>
<script type="text/javascript" src="<?=PATH_URL.'static/js/audio-player/audio-player.js'?>"></script>
<script type="text/javascript" src="<?=PATH_URL.'static/js/admin/jwplayer.js'?>"></script>
<script type="text/javascript" src="<?=PATH_URL.'static/js/jquery.uploadify/swfobject.js'?>"></script>
<script type="text/javascript" src="<?=PATH_URL.'static/js/jquery.uploadify/jquery.uploadify.v2.1.4.min.js'?>"></script>
<script type="text/javascript" src="<?=PATH_URL.'static/js/admin/jquery.validate.min.js'?>"></script>
<script type="text/javascript" src="<?=PATH_URL.'static/js/admin/jquery.cookie.js'?>"></script>
<script type="text/javascript" src="<?=PATH_URL.'static/js/admin/jquery.timepaker.js'?>"></script>
<script type="text/javascript" src="<?=PATH_URL.'static/js/admin/shortcut.js'?>"></script>
<script type="text/javascript" src="<?=PATH_URL.'static/js/admin/json2.js'?>"></script>


<title>Admin Control Panel</title>
<!--[if ie 6]>
<style>
html, body{
behavior: url('<?php echo PATH_URL.'static/css/' ?>csshover3.htc');
}

.png{
behavior: url('<?php echo PATH_URL.'static/css/' ?>iepngfix.htc');
}
</style>
<script type="text/javascript" src="<?php echo PATH_URL.'static/js/' ?>iepngfix_tilebg.js"></script>
<![endif]-->
<script type="text/javascript">
var SET_WIDTH_INTERVAL = 500;
var force_collpase = 'off';
var right_content_width = 0;


function set_width_parent_td(selector) {
	var child_width = $(selector).width();
	var parent_td = $(selector).parent();
	parent_td.width(child_width);
}

function set_width_for_fixed_element() {
	right_content_width = $('.right_content').width();
	set_width_for_fixed_container_element();
	
	if (!$('.table-up .tr-top').length) {
		set_body_column_width_by_header('.table-under tr th#column_header_number', 30);
		set_body_column_width_by_header('.table-under tr th#column_header_checkbox', 30);
		set_body_column_width_by_header('.table-under tr th#column_header_created', 100);
		set_body_column_width_by_header('.table-under tr th#column_header_status', 70);
		set_body_column_width_by_header('.table-under tr th#column_header_action', 180);		
		$('.table-under .tr-top').clone().appendTo('.table-up');
	}
	copy_width();
}

function copy_width() {
	$('.table-under .tr-top th').each(function () {
		var current_index = $(this).index();
		var next_parent = $('.table-up .tr-top');
		var corresponding_td = next_parent.children().eq(current_index);
		var td_width = $(this).width();
		corresponding_td.width(td_width);
	});
}
function set_body_column_width_by_header(header_selector, td_width) {
	/* var current_index = $(header_selector).index();
	var next_parent = $('.table-under tr td:first').parent();
	var corresponding_td = next_parent.children().eq(current_index);
	corresponding_td.width(td_width); */
	$(header_selector).width(td_width);
}

function set_width_for_fixed_container_element() {
	$('.head_table_1').width(right_content_width);
	$('.head_table_2').width(right_content_width);
	$('.head_table').width(right_content_width);
	$('.indexView').width(right_content_width);
	$('.table-up').width(right_content_width);
}

function toogle_collapse() {
	/* 	Toogle force_collpase */
	if (force_collpase === 'on') {
		force_collpase = 'off';
	} else {
		force_collpase = 'on';
	}
	
	/* 	Set cookie here */
	$.cookie("force_collpase", force_collpase, {
		expires : 1
	});
	
	$('td.menu').fadeToggle("fast");
	$('.collapse_icon').toggleClass("active");
	right_content_width = $('td.right_content_td').width() - $('.left_content').width();
	if ($('td.menu').is(':visible')) {
		set_width_for_fixed_container_element();
	}
	setTimeout("set_width_for_fixed_element()", SET_WIDTH_INTERVAL);
}

$(document).ready(function () {
	$('#caledar_from').click(function(){
		/* var offset = $(this).offset();
		var scrollTop = $('.head_table_2').scrollTop();
		console.log('scrollTop = ' + scrollTop);
		var height = $(this).height();
		console.log('offset-top = ' + offset.top + ' offset-left =' + offset.left);
		console.log('offset-height = ' + height);
		var distance = offset.top + height;
		console.log('distance = ' + distance);
		$('#ui-datepicker-div').css('top',distance); */
		$('#ui-datepicker-div').css('top','184px');
	});
	$('#caledar_to').click(function(){
		$('#ui-datepicker-div').css('top','184px');
	});
	set_width_parent_td('.left_content');
	set_width_parent_td('.collapse_icon');	
	setTimeout("set_width_for_fixed_element()", SET_WIDTH_INTERVAL);	
	$('.collapse_icon').click(toogle_collapse);
	
	/*  Get cookie */
	force_collpase = $.cookie("force_collpase");
	if (force_collpase === 'on') {
		force_collpase = 'off';
		toogle_collapse();
	}
});

</script>
</head>
<body>
<div class="topNav">
	<div class="nameNav">Auction Admin</div>
	<div class="userNav">
		<ul>
			<li class="profile"><a href="<?=PATH_URL.'admincp/update_profile'?>"><img alt="profile" src="<?=PATH_URL.'static/images/admin/userPic.png'?>" /><span><?=$this->session->userdata('userInfo')?></span></a></li>
			<li class="li_last_child"><a href="<?=PATH_URL.'admincp/logout'?>"><img alt="profile" src="<?=PATH_URL.'static/images/admin/logout.png'?>" /><span>Logout</span></a></li>
		</ul>
	</div>
</div>

<div class="header">
	<div class="logo">
		<!-- <img alt="" src="<?=PATH_URL.'static/images/admin/logo.png'?>" /> -->
	</div>
	<?php
	if($module!='permission'){
	?>
	<div class="midNav">
		<?php
		if($this->uri->segment(3)!='update' && $module!='update_profile'){
			if($module!='manager_modules'){
		?>
		<ul>
			<?php if($module!='contact'){ ?>
			<li><a href="<?=PATH_URL.'admincp/'.$module.'/update/'?>"><span class="add_new">Add new</span></a></li>
			<li><a href="javascript:void(0)" onclick="showStatusAll()"><span class="show_items">Show</span></a></li>
			<li><a href="javascript:void(0)" onclick="hideStatusAll()"><span class="hide_items">Hide</span></a></li>
			<?php } ?>
			<li class="midNav_last_child"><a href="javascript:void(0)" onclick="deleteAll()"><span class="delete_items">Delete</span></a></li>
		</ul>
		<?php
			}
		} else {
		?>
		<ul>
			<?php
			if($module!='update_profile'){
			?>
			<li id='button_back' <?=$module=='contact'? 'class="midNav_last_child"':''?>><a href="<?=PATH_URL.'admincp/'.$module.'/#/back'?>" title="Go back (Ctrl+Alt+B)"><span class="back"><u>B</u>ack</span></a></li>
			<?php
			}
			if($module=='accounts' && $this->uri->segment(4)!=''){
			?>
			<li><a href="javascript:void(0)" onclick="resetPerm()"><span class="reset">Reset Permission</span></a></li>
			<?php
			}
			if($module!='contact'){
			?>
			<li><a href="javascript:void(0)" onclick="apply()"><span class="apply" title="Save and Stay (Ctrl+Alt+A)"><u>A</u>pply</span></a></li>
			<li><a href="javascript:void(0)" onclick="save()"><span class="save" title="Save and Exit (Ctrl+Alt+S)"><u>S</u>ave&amp;exit</span></a></li>
			<li class="midNav_last_child"><a href="javascript:void(0)" onclick="save_new()" title="Save and Add new (Ctrl+Alt+N)"><span id="" class="save">Save&amp;<u>n</u>ew</span></a></li>
			<?php
			}
			?>
		</ul>
		<?php
		}
		?>
	</div>
	<?php
	}
	?>
</div>

<div id="content">
	<table cellspacing="0" cellpadding="0" border="0" width="100%" class='content_table'>
		<tr>
			<td valign="top" class="menu">
				<div class="left_content">
					<?=modules::run('admincp/menu')?>
				</div>
			</td>
			<td valign="top" class="collapse_icon_td"><div class="collapse_icon"></div></td>
			<td valign="top" class="right_content_td" style="padding-left:2px;padding-right:2px;">
				<div class="right_content" <?=$module == 'admincp' ? 'style="padding-top:0;"' : ''?>>
					<?=$content?>
				</div>
			</td>
		</tr>
	</table>
</div>

<div class="footer"><div class="text_footer">&copy; Copyright 2013. All rights reserved.</div></div>

<div id="loader">
	<div class="bg_mask"></div>
	<div class="processing">
		<div class="bg_processing"><img alt="Loading" src="<?=PATH_URL.'static/images/admin/ajax-loader.gif'?>" /><br/>System is processing...</div>
	</div>
</div>
</body>

</html>